package com.shqcjd.sinopecdemomobile.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.sinopecdemomobile.R;
import com.shqcjd.sinopecdemomobile.model.pojo.EquipmentGroupBean;

import java.util.List;

public class EquipmentGroupStandardContentAdapter extends BaseQuickAdapter<EquipmentGroupBean.EquipmentStandardBean.EquipmentTypePartBean,EquipmentGroupStandardContentAdapter.ViewHolder> {
    private Context context;
    private List<EquipmentGroupBean.EquipmentStandardBean.EquipmentTypePartBean> data;

    public EquipmentGroupStandardContentAdapter(@Nullable List<EquipmentGroupBean.EquipmentStandardBean.EquipmentTypePartBean> data, Context context) {
        super(R.layout.item_equipment_group_standard_content, data);
        this.context = context;
        this.data = data;
    }

    @Override
    protected void convert(ViewHolder helper, EquipmentGroupBean.EquipmentStandardBean.EquipmentTypePartBean item) {
        helper.tv_item_equipment_group_content_name.setText(item.equipment_type_part_name);
        helper.rv_item_equipment_group_content.setLayoutManager(new LinearLayoutManager(context));
        EquipmentGroupStandardItemAdapter equipmentGroupStandardItemAdapter = new EquipmentGroupStandardItemAdapter(item.equipment_type_part_item, context);
        helper.rv_item_equipment_group_content.setAdapter(equipmentGroupStandardItemAdapter);
    }

    class ViewHolder extends BaseViewHolder {
        private RecyclerView rv_item_equipment_group_content;
        private TextView tv_item_equipment_group_content_name;
        ViewHolder(View itemView) {
            super(itemView);
            rv_item_equipment_group_content = itemView.findViewById(R.id.rv_item_equipment_group_content);
            tv_item_equipment_group_content_name = itemView.findViewById(R.id.tv_item_equipment_group_content_name);
        }
    }
}